\rcube_charset

Character sets conversion functionality

Summary

Methods
Properties
Constants
parse_charset()
convert()
utf7_to_utf8()
utf16_to_utf8()
utf7imap_to_utf8()
utf8_to_utf7imap()
detect()
clean()
$aliases
$windows_codepages
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$aliases

$aliases : array

Character set aliases (some of them from HTML5 spec.)

Type

array

$windows_codepages

$windows_codepages : array

Windows codepages

Type

array

Methods

parse_charset()

parse_charset(string  $input) : string

Parse and validate charset name string.

Sometimes charset string is malformed, there are also charset aliases, but we need strict names for charset conversion (specially utf8 class)

Parameters

string $input

Input charset name

Returns

string —

The validated charset name

convert()

convert(string  $str, string  $from, string  $to = null) : string

Convert a string from one charset to another.

Parameters

string $str

Input string

string $from

Suspected charset of the input string

string $to

Target charset to convert to; defaults to RCUBE_CHARSET

Returns

string —

Converted string

utf7_to_utf8()

utf7_to_utf8(string  $str) : string

Converts string from standard UTF-7 (RFC 2152) to UTF-8.

Parameters

string $str

Input string (UTF-7)

Returns

string —

Converted string (UTF-8)

utf16_to_utf8()

utf16_to_utf8(string  $str) : string

Converts string from UTF-16 to UTF-8 (helper for utf-7 to utf-8 conversion)

Parameters

string $str

Input string

Returns

string —

The converted string

utf7imap_to_utf8()

utf7imap_to_utf8(string  $str) : string

Convert the data ($str) from RFC 2060's UTF-7 to UTF-8.

If input data is invalid, return the original input string. RFC 2060 obviously intends the encoding to be unique (see point 5 in section 5.1.3), so we reject any non-canonical form, such as &ACY- (instead of &-) or &AMA-&AMA- (instead of &AMAAwA-).

Parameters

string $str

Input string (UTF7-IMAP)

Returns

string —

Output string (UTF-8)

utf8_to_utf7imap()

utf8_to_utf7imap(string  $str) : string

Convert the data ($str) from UTF-8 to RFC 2060's UTF-7.

Unicode characters above U+FFFF are replaced by U+FFFE. If input data is invalid, return an empty string.

Parameters

string $str

Input string (UTF-8)

Returns

string —

Output string (UTF7-IMAP)

detect()

detect(string  $string, string  $failover = null, string  $language = null) : string

A method to guess character set of a string.

Parameters

string $string

String

string $failover

Default result for failover

string $language

User language

Returns

string —

Charset name

clean()

clean(mixed  $input) : mixed

Removes non-unicode characters from input.

If the input is an array, both values and keys will be cleaned up.

Parameters

mixed $input

String or array.

Returns

mixed —

String or array